$(function () {
    $.ajax(`${baseUrl}/users`, {
        success: function (res) {
            // console.log("获取数据成功")
            const newHtml = template("users-temp", { userList: res })
            // console.log(newHtml)
            $(".table tbody").html(newHtml)
            $(".row .btn").click(function () {})
            $(".del").click(function (e) {
                // e.preventDefault()
                const uid = $(this).parent().parent().attr("data-id")
                $.ajax(`${baseUrl}/users/${uid}`, {
                    type: "delete",
                    success: function () {
                        alert("删除成功")
                    },
                    error: err => alert("删除失败"),
                })
            })
        },
        error: err => console.log(err),
    })
})
